package com.ruoyi.web.lambda;

/**
 * @Program: RuoYi-Vue-chy->AddableDemo2
 * @Description:
 * @Author: hongyu.chen
 * @Date: 2025-03-07 17:32
 * @Version： 1.0
 **/
public class AddableDemo2 {
    public static void main(String[] args) {
        //匿名内部类
        useInter(new Inter() {
            @Override
            public void show() {
                System.out.println("show接口");
            }

            @Override
            public void show2() {
                System.out.println("show2接口");
            }
        });

        useAnimal(new Animal() {
            @Override
            public void method() {
                System.out.println("抽象类");
            }
        });

        useStudent(new Student() {
            @Override
            public void study() {
                System.out.println("具体类");
            }
        });

        //useInter
//        useInter(() -> System.out.println("show接口2"));
//        useAnimal(() -> System.out.println("抽象类2"));
//        useStudent(() -> System.out.println("具体类2"));

    }

    private static void useStudent(Student student) {
        student.study();
    }

    private static void useAnimal(Animal animal) {
        animal.method();
    }

    private static void useInter(Inter inter) {
        inter.show();
    }
}
